How to use Locust for load testing
We need to create a navigation script (.py) to launch a scenario.
For this, use your browser and with the network console save the all as HAR with content.
On the load testing server, we install "transformer" which is a python script which will translate the HAR into a script compatible with Locust :
pip3 install har-transformer
To translate the HAR file :
transformer my_har_files_directory/ >locustfile.py
Locust
Launch a scenario
After we have our .py script, we first need to know that locust is mono thread. So, it will only use one CPU if we run it without a "worker". If you want to use 4 cores, start a Locust "master" then 4 "workers".
Master launch with 100 users every 1 second
locust --host=https://xxx.yyy -u100 -r1 --locustfile locust.py --master
One worker launch
locust --locustfile locust.py --worker --master-host=127.0.0.1
Web UI
To access the web UI, default port is on 8089 so we can access by http://xxx.yyy:8089